<template>
    <div>
        <el-button v-if="vBack" type="success" size="small" icon="caret-left"
                   style="margin: 10px 0 0 10px" @click="back()">{{returnTitle}}</el-button>

            <el-tabs v-model="activeTab">
                <el-tab-pane name="tab_1">
                    <span slot="label"><i class="el-icon-view"></i> 客户详情 </span>
                    <CustomerDetail ref="customerDetail"></CustomerDetail>
                </el-tab-pane>
                <el-tab-pane name="tab_2">
                    <span slot="label"><i class="el-icon-date"></i> 联系人</span>
                    <Contacts ref="contacts"></Contacts>
                </el-tab-pane>
                <el-tab-pane  name="tab_3">
                    <span slot="label"><i class="el-icon-document"></i> 项目</span>
                    <Project ref="project"></Project>
                </el-tab-pane>
                <el-tab-pane  name="tab_4">
                    <span slot="label"><i class="el-icon-document"></i>合同</span>
                    <sy-baselist
                            ref="cList"
                            fixOperate
                            :showFilterCount="2"
                            hideAdd
                            hideOperate
                            listUrl="server/customer/Contract.ashx?cmd=GetList"
                    >
                        <el-table-column prop="FNo"  header-align="center" label="合同编号" width="110">
                        </el-table-column>
                        <el-table-column prop="CustomerName"  header-align="center" label="客户名称" width="220" sortable>
                        </el-table-column>
                        <el-table-column prop="FProjectName"  header-align="center" label="项目申报名称" width="300" sortable>
                        </el-table-column>
                        <el-table-column prop="FBankrollType"  header-align="center" label="申报资金种类" width="320">
                        </el-table-column>
                        <el-table-column prop="UserName"  header-align="center" label="跟单员" width="160" >
                        </el-table-column>
                        <el-table-column prop="FDeadline"  header-align="center" label="资金年限" width="120">
                        </el-table-column>
                        <el-table-column prop="FGrade"  header-align="center" label="申报等级" width="120" sortable>
                        </el-table-column>
                        <el-table-column  prop="FCommission"  header-align="center" label="业务提成" width="160">
                        </el-table-column>
                        <el-table-column prop="Provice"  header-align="center" label="省份" width="100" sortable>
                        </el-table-column>
                        <el-table-column prop="City"  header-align="center" label="城市" width="100" sortable>
                        </el-table-column>
                        <el-table-column prop="IsBankroll"  header-align="center" label="是否获取资金" width="100" >
                        </el-table-column>
                        <el-table-column  prop="FPayWay"  header-align="center" label="付款方式" width="100">
                        </el-table-column>
                        <el-table-column  prop="FCustCommission"  header-align="center" label="合同点数(%)" :formatter="formatPercent"  width="100">
                        </el-table-column>
                        <el-table-column  prop="FAmount"  header-align="center" label="获得扶持资金总额" :formatter="formatMoney" width="100">
                        </el-table-column>
                        <el-table-column  prop="ToAmount"  header-align="center" label="应得咨询费总额" :formatter="formatMoney" width="95">
                        </el-table-column>
                        <el-table-column  prop="FActAmount"  header-align="center" label="实际咨询费总额" :formatter="formatMoney" width="95">
                        </el-table-column>
                        <el-table-column  prop="FPayedAmount"  header-align="center" label="已付金额" :formatter="formatMoney" width="100">
                        </el-table-column>
                        <el-table-column  prop="PayedAll"  header-align="center" label="是否欠款" width="70" >
                        </el-table-column>
                        <el-table-column prop="FCounselor"  header-align="center" label="咨询师" width="80" >
                        </el-table-column>
                        <el-table-column prop="FNote"  header-align="center" label="备注" width="250" >
                        </el-table-column>
                        <el-table-column prop="FCompletedDate"  header-align="center" label="合同签订时间" :formatter="formatDate" width="130" >
                        </el-table-column>
                        <el-table-column prop="FToCompletedDate"  header-align="center" label="合同完成时间" :formatter="formatDate" width="130" >
                        </el-table-column>
                    </sy-baselist>
                </el-tab-pane>
                <el-tab-pane  name="tab_5">
                    <span slot="label"><i class="el-icon-document"></i>跟进日志</span>
                    <sy-baselist
                            ref="projectTrace"
                            title="项目跟踪"
                            @beforeAdd="beforeAddTrace"
                            :autoSearch="false"
                            :fixWhere="'FType=0 and FCustID='+custID"
                            editVue="./customer/ProjectTrace_Edit.vue"
                            listUrl="server/customer/ProjectTrace.ashx?cmd=GetList"
                            deleteUrl="server/customer/ProjectTrace.ashx?cmd=Delete"
                    >
                        <el-table-column prop="FCreateDate" label="跟进时间" :formatter="formatDate" width="110" >
                        </el-table-column>
                        <el-table-column prop="FLinkMan" label="客方联系人"  width="110" >
                        </el-table-column>
                        <el-table-column prop="FLinkPhone" label="客方联系电话"  width="150" >
                        </el-table-column>
                        <el-table-column prop="FContent" label="跟进内容" width="450" >
                        </el-table-column>
                        <el-table-column prop="FTalkTime" label="通话时长(分钟)"  width="150" >
                        </el-table-column>
                        <el-table-column prop="FRealName" label="跟进人"  width="160" >
                        </el-table-column>
                        <el-table-column prop="FMyPhone"  header-align="center" label="拨出电话号码"  width="130" >
                        </el-table-column>
                        <el-table-column prop="FToDate" label="再跟进时间" :formatter="formatDate" width="110">
                        </el-table-column>
                    </sy-baselist>
                </el-tab-pane>
            </el-tabs>
    </div>
</template>

<script>
    import util from '../../common/util'
    import mixin from '../../common/mixin'
    import Contacts from "./Contacts.vue"
    import Project from "./Project.vue"
    import CustomerDetail from "./Customer_Detail.vue"

    export default {
        mixins: [mixin],
        components:{
            Contacts:Contacts,
            Project:Project,
            CustomerDetail:CustomerDetail
        },
        data(){
            return {
                returnTitle:"返回",
                activeTab:"tab_1",
                custID:0,
                vBack:false
            }
        },
        methods:{
            _init(row){
                //组件嵌入
                this.activeTab = "tab_1"
                this.$refs.customerDetail._init(row)
                this.$refs.contacts._init(row.FID)
                this.$refs.project._init(row.FID)
                this.custID = row.FID
            },
            _initByID(custID){
                //组件嵌入
                this.custID = custID
                let url = "server/customer/Customer.ashx?cmd=GetOne"
                util.get(url,{FID:this.custID},null,result=> {
                    this._init(result.data)
                })
            },
            back(){
                this.$router.go(-1)
            },
            beforeAddTrace(row,r){
                row.FCustID = this.custID
            },
            formatPercent(row, column) {
                return row[column.property] + "%"
            },
            formatMoney(row, column) {
                return row[column.property] + "万"
            },
            formatMoney2(row, column) {
                return row[column.property] + "元"
            }
        },
        created(){
            //使用链接
            this.custID = this.$router.currentRoute.query.custID
            if(this.custID){
                this.vBack = true
                this._initByID(this.custID)
            }
        }
    }
</script>
